﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using YasharEl.Infrastructure.ObjectFactory;

namespace YasharEl.Infrastructure.Caching.Configuration
{
    public partial class CacheManagerConfig
    {
        public void DeserializeElement(XmlReader reader)
        {
            base.DeserializeElement(reader, false);
        }

        public virtual ICacheManager CreateCacheManager(IDependencyRegistrar dependencyRegistrar)
        {
            try
            {
                ICacheManagerFactory cacheManagerFactory = (ICacheManagerFactory)Activator.CreateInstance(CacheManagerFactory);
                return cacheManagerFactory.CreateCacheManager(this, dependencyRegistrar);
            }
            catch (Exception e)
            {
                throw new InvalidSystemConfigurationException(string.Format("Could not recognize cache factory {0}", CacheManagerFactory.FullNameToString()), e);
            }
        }
    }
}
